package com.guoheng.hazard.sys.controller.entpr;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.entpr.EntprEnvrInfoInsertDTO;
import com.guoheng.hazard.sys.model.dto.entpr.EntprEnvrInfoUpdateDTO;
import com.guoheng.hazard.sys.service.entpr.EntprEnvrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;

/**
 * 类功能描述:　企业周边环境信息
 *
 * @author fbl
 * @date 2019-11-12 10:09
 */
@RestController
@Validated
@Api(value = "企业周边环境信息")
public class EntprEnvrController {

    @Resource
    EntprEnvrService entprEnvrService;

    @ApiOperation(value = "查询企业周边环境信息列表")
    @GetMapping(value = "data/basic/enterprise/environments")
    public Result getEntprEnvironments(Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return entprEnvrService.getEntprEnvironments(entprId, pageNum, pageSize);
    }

    @ApiOperation(value = "修改企业周边环境信息")
    @PutMapping(value = "data/basic/enterprise/environments")
    public Result updateEntprEnvironments(@RequestBody @Valid EntprEnvrInfoUpdateDTO entprEnvrInfoUpdateDTO) {
        return entprEnvrService.updateEntprEnvironments(entprEnvrInfoUpdateDTO);
    }

    @ApiOperation(value = "新增企业周边环境信息")
    @PostMapping(value = "data/basic/enterprise/environments")
    public Result insertEntprEnvironments(@RequestBody @Valid EntprEnvrInfoInsertDTO entprEnvrInfoInsertDTO) {
        return entprEnvrService.insertEntprEnvironments(entprEnvrInfoInsertDTO);
    }

    @ApiOperation(value = "删除企业周边环境信息")
    @DeleteMapping(value = "data/basic/enterprise/environments/{id}")
    public Result deleteEntprEnvironments(@PathVariable Long id) {
        return entprEnvrService.deleteEntprEnvironments(id);
    }

    @ApiOperation(value = "查询企业周边环境信息详情")
    @GetMapping(value = "data/basic/enterprise/environments/{id}")
    public Result selectEntprEnvironmentById(@PathVariable @NotNull Long id) {
        return entprEnvrService.selectEntprEnvironmentById(id);
    }
}